import { defineNuxtConfig } from 'nuxt/config'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'

export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: false },
  modules: ['@pinia/nuxt', '@nuxt/eslint', 'nuxtjs-naive-ui'],
  vite: {
    plugins: [
      AutoImport({
        imports: [
          {
            'naive-ui': [
              'useDialog', // 移除这行
              'useMessage',
              'useNotification',
              'useLoadingBar'
            ]
          }
        ],
        dts: './types/auto-imports.d.ts' // 自定义生成路径
      }),
      Components({
        resolvers: [NaiveUiResolver()],
        dts: './types/components.d.ts' // 自定义生成路径
      }),
    ],
    // 添加以下配置以处理CommonJS模块兼容性问题
    optimizeDeps: {
      include: ['vueuc']
    }
  },
  // 运行时配置
  runtimeConfig: {
    public: {
      apiBaseUrl: process.env.NUXT_PUBLIC_API_BASE_URL || 'http://localhost:6363/api',
    }
  },
  css: [
    '~/assets/styles/main.scss'
  ],
  // 添加路径别名配置
  alias: {
    '@server': resolve(__dirname, './server'),
  },
  // 添加转译配置
  build: {
    transpile: [
      'naive-ui',
      'vueuc',
      '@css-render/vue3-ssr',
      '@juggle/resize-observer'
    ]
  }
})